package com.ruoyi.system.service.news.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.ruoyi.system.domain.news.NewsImportantSecurity;
import com.ruoyi.system.domain.news.query.NewsImportantSecurityQuery;
import com.ruoyi.system.domain.news.vo.NewsImportantSecurityVo;
import com.ruoyi.system.domain.news.vo.NewsImportantSecurityVo;
import com.ruoyi.system.mapper.news.NewsImportantSecurityMapper;
import com.ruoyi.system.service.news.NewsImportantSecurityService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@Slf4j
public class NewsImportantSecurityServiceImpl extends ServiceImpl<NewsImportantSecurityMapper, NewsImportantSecurity>
        implements NewsImportantSecurityService {

    @Override
//    @DataScope(deptAlias = "t",userAlias = "t")
    public List<NewsImportantSecurityVo> getNewsImportantSecurityList(NewsImportantSecurityQuery newsImportantSecurityQuery) {
        if (newsImportantSecurityQuery.getIfPage()) {
            PageHelper.startPage(newsImportantSecurityQuery.getPageNum(), newsImportantSecurityQuery.getPageSize());
        }
        List<NewsImportantSecurityVo> newsImportantSecurityVoList = baseMapper.getNewsImportantSecurityList(newsImportantSecurityQuery);
        if (!newsImportantSecurityVoList.isEmpty() && newsImportantSecurityQuery.getId() == null) {
            for (NewsImportantSecurityVo newsImportantSecurityVo:newsImportantSecurityVoList) {
                newsImportantSecurityVo.setContent(null);
            }
        }
        return newsImportantSecurityVoList;
    }
}
